package com.alameda.service.user;

import com.alameda.common.commonpent.mp.BaseService;
import com.alameda.common.utils.PubUtils;
import com.alameda.pojo.user.AdUserOrganizationDO;
import com.alameda.user.dto.AdUserOrganizationDTO;
import com.alameda.user.vo.AdUserOrganizationVO;
import com.baomidou.mybatisplus.core.metadata.IPage;

import java.util.List;

/**
 * 用户组织 业务逻辑层
 *
 * @author Lv
 * @date 2024/04/27
 */
public interface AdUserOrganizationService extends BaseService<AdUserOrganizationDO> {
    /**
     * 查询组织列表
     *
     * @param adUserOrganizationDTO 用户组织信息
     * @return
     */
    IPage<AdUserOrganizationVO> listOrganization(AdUserOrganizationDTO adUserOrganizationDTO);

    /**
     * 导出excel
     *
     * @param adUserOrganizationDTO 用户组织信息
     */
    void export(AdUserOrganizationDTO adUserOrganizationDTO);

    /**
     * 获取一级组织信息
     *
     * @param adUserOrganizationDTO 用户组织信息
     * @return
     */
    default List<AdUserOrganizationDO> findUserOrganization(AdUserOrganizationDTO adUserOrganizationDTO) {
        return this.lambdaQuery()
                .notIn(PubUtils.isNotNull(adUserOrganizationDTO.getId()), AdUserOrganizationDO::getId, adUserOrganizationDTO.getId())
                .isNull(AdUserOrganizationDO::getParentId)
                .list();
    }

    /**
     * 删除组织信息
     *
     * @param idList 组织id集合
     * @return
     */
    Boolean deleteByIds(List<Long> idList);

    /**
     * 加载所有子组织下拉框
     *
     * @return
     */
    default List<AdUserOrganizationDO> loadAllSonOrganization() {
        return this.lambdaQuery()
                .isNotNull(AdUserOrganizationDO::getParentId)
                .list();
    }
}
